<?php
namespace app\admin\validate;

use think\Validate;

class PhoneValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'phone' => 'require|number|mobile',
        'code' => 'require|number',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'phone.require' => '请填写手机号码',
        'phone.number' => '您输入的手机号码必须为数字',
        'phone.mobile' => '您输入的手机号码有误',
        'code.require' => '请填写短信验证码',
        'code.number' => '短信验证码必须为数字',
    ];

    protected $scene = [
        'login' => ['phone', 'code'],
        'phone' => ['phone']
    ];
}
